package string;

import java.util.Arrays;

/** String[] split(String regex) 拆分 */
public class SplitDemo {
    public static void main(String[] args) {
        String line = "abc123asknfl45dif852";
        String[] data = line.split("[0-8]+");//按数字拆分
        System.out.println(Arrays.toString(data));

        line = "123.123.456.789...";
        data = line.split("\\.");
        System.out.println(Arrays.toString(data));

        //最开始就是可拆分项，那么数组第1个元素为空字符串.............""
        //如果连续两个(两个以上)可拆分项，那么中间也拆出一个控字符串...""
        //如果末尾连续多个可拆分项，那么拆出的空字符串被忽略(不要了)
        line = ".123.456...789.7....";
        data = line.split("\\.");
        System.out.println(Arrays.toString(data));
        System.out.println(data.length);

        String s1 = "sjd18sd64f5d4df6s4";
        String[] str = s1.split("[0-8]+");
        System.out.println(Arrays.toString(str));
    }
}
